<!--待确认-->
<template>
  <div>
    <el-form :model="checkForm" label-width="100px" class="demo-ruleForm" ref="checkForm">
      <el-form-item label="办理结果" prop="approveStatus"  :rules="[{ required: true, message: '请选择办理结果', trigger: 'change' }]" label-width="150px">
        <el-radio-group v-model="checkForm.approveStatus" @change="handleChange">
          <!-- <el-radio label="8" class="green">复议</el-radio> -->
          <el-radio label="3" class="red">退件</el-radio>
          <el-radio label="5" class="red">拒件</el-radio>
          <el-radio label="9" class="red">通过</el-radio>
        </el-radio-group>
      </el-form-item>

      <el-form-item label="预约合同签约时间" prop="makeContractSignTime" v-if="checkForm.approveStatus == 9" label-width="150px"
        :rules="[{ required: true, message: '合同签约时间不能为空', trigger: 'blur' }]">
        <el-date-picker v-model="checkForm.makeContractSignTime" type="datetime" placeholder="选择日期" style="width: 300px" value-format="yyyy-MM-dd HH:mm:ss">
        </el-date-picker>
      </el-form-item>

      <el-form-item label="预约公证时间" prop="makeNotaryTime" v-if="checkForm.approveStatus == 9" label-width="150px"
        :rules="[{ required: true, message: '公证时间不能为空', trigger: 'blur' }]">
        <el-date-picker v-model="checkForm.makeNotaryTime" type="datetime" placeholder="选择日期" style="width: 300px" value-format="yyyy-MM-dd HH:mm:ss"> </el-date-picker>
      </el-form-item>

      <el-form-item label="预约办押时间" prop="makePledgeTime" v-if="checkForm.approveStatus == 9" label-width="150px"
        :rules="[{ required: true, message: '办押时间不能为空', trigger: 'blur' }]">
        <el-date-picker v-model="checkForm.makePledgeTime" type="datetime" placeholder="选择日期" style="width: 300px" value-format="yyyy-MM-dd HH:mm:ss"> </el-date-picker>
      </el-form-item>

      <el-form-item label="反馈信息" prop="opinion" label-width="150px">
        <el-input type="textarea" :rows="7" v-model="checkForm.opinion" style="width: 300px"></el-input>
      </el-form-item>

      <el-form-item>
        <el-button type="primary" @click="submitForm('checkForm')" v-loading="loading">提交</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>
<script>
import { toBeComfirmed } from '@/api/project';
export default {
   props: {
     projectId: undefined,
     taskId: undefined
  },
  data() {
    return {
      checkForm: {
        approveStatus: undefined,
        makeContractSignTime: undefined,
        makePledgeTime: undefined,
        makeNotaryTime: undefined,
        opinion: undefined,
      },
      loading: false
    };
  },

  methods: {
    submitForm(checkForm) {
      this.$refs[checkForm].validate((valid) => {
          if (valid) {
            this.checkForm.projectId = this.projectId,
            this.checkForm.taskId = this.taskId,
            this.$confirm('你确定要提交吗?', '提示', {
              confirmButtonText: '确定',
              cancelButtonText: '取消',
              type: 'warning',
            }).then(() => {
              // 开始提交信息
              this.loading = true;
              toBeComfirmed(this.checkForm).then((data) => {
                this.loading = false;
               this.$notify.success({
                title: '成功',
                message: '操作成功'
              })
                this.$store.dispatch("tagsView/delView", this.$route);
                this.$router.go(-1);
              }).catch(() => {
                this.loading = false;
              })
            });
          } else {
            return false;
          }
        });
    },
    //节点判断
    handleChange(val) {
      this.restForm();
      this.checkForm.approveStatus = val;
      return;
    },
    restForm() {
      this.checkForm = {
        opinion: undefined,
        makeNotaryTime: undefined,
        approveStatus: undefined,
        makePledgeTime: undefined,
        makeContractSignTime: undefined,
      };
    },
  },
};
</script>
